<?php

namespace Admin\Controller;
use Think\Controller\JsonRpcController;
class ServerController extends JsonRpcController {
    //responseURL()---->url执行函数
    //初始方法
    protected function _initialize(){

           /*$module = $_GET['module'];
           $action = $_GET['action'];
           $token = md5($module.date('Y-m-d',time()).'#$@%!*'.$action);
           if($token != $_GET['token']){
               echo('access deny');
               exit();
           }*/
    }


    public function index(){
        $id = $_GET['id'];
        $r = M("plant")->where("id=".$id)->find();
        echo $this->response(200,'OK',$r);
    }


    //处理数据，转换为json数据
    public function response($code, $message = '', $data = array()) {
        if(!(is_numeric($code))) {
            return '';
        }
        $result = array(
            'code' => $code,
            'message' => $message,
            'data' => $data
        );

        echo json_encode($result);
        exit;
    }
}
?>